﻿using Gateway.Common.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Gateway.Domain.EFCore.Configuration
{
    public class EntityConfiguration<T> : IEntityTypeConfiguration<T> where T : EntityBase
    {
        public virtual void Configure(EntityTypeBuilder<T> builder)
        {
            Type genericType = typeof(T);
            builder.HasKey(x => x.Id);
            builder.Property(x => x.Id).HasColumnName(genericType.Name + "Id").IsRequired().HasMaxLength(36).HasComment("主键");
            builder.ToTable(genericType.Name);
        }
    }
}
